(require 'electric)
;; auto pair ()
(electric-pair-mode t)
;; auto indent
(electric-indent-mode t)
;; disable auto enter
(electric-layout-mode 0)
(global-font-lock-mode 1)

;; Set tab width
(setq-default tab-width 4
              indent-tabs-mode nil)
;; highlight todo
(add-hook 'prog-mode-hook 'hl-todo-mode)
;; display unicode symbols
(add-hook 'prog-mode-hook 'pretty-symbols-mode)
(dolist (command '(yank yank-pop))
  (eval
   `(defadvice ,command (after indent-region activate)
      (and (not current-prefix-arg)
           (member major-mode
                   '(emacs-lisp-mode
                     lisp-mode
                     python-mode
                     latex-mode
                     plain-tex-mode))
           (let ((mark-even-if-inactive
                  transient-mark-mode))
     (indent-region (region-beginning)
                    (region-end) nil))))))
;; use company-mode
(add-hook 'after-init-hook 'global-company-mode)
(add-to-list 'company-backends 'company-yasnippet)

;; set yasnippet
(yas-global-mode 1)
(yas-minor-mode-on)
(define-key yas-minor-mode-map [(tab)] nil)
(define-key yas-minor-mode-map (kbd "TAB") nil)
(define-key yas-minor-mode-map (kbd "C-;") 'yas-expand)

;; set company
(setq compandy-minimum-prefix-length 1)
(setq company-tooltip-align-annotations t)
(setq company-transformers '(company-sort-by-occurrence))
(setq company-selection-wrap-around t)
(setq company-tooltip-limit 10)


;; damacs-code end
(provide 'damacs-code)
